package com.base.controller;

import com.base.service.CompanyClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * 方案分类
 *
 * @author f
 */
@Controller
@RequestMapping("/admin")
public class index_CompanyClassify {

    @Autowired
    private CompanyClassifyService companyClassifyService; // 分类信息

    // 分类广告首页
    @RequestMapping("/companyClassifyIndex")
    public ModelAndView companyClassifyIndex(HttpServletRequest request) {
        String userid = (String) request.getSession().getAttribute("adminUserId"); // 登录的用户ID
        if (userid == null) return new ModelAndView("jsp/loginCheck"); // 未登录
        return new ModelAndView("jsp/index_CompanyClassify", "sClassifyList", companyClassifyService.selectByAll(userid));
    }

    // 跳转添加分类
    @RequestMapping("/addCompanyClassify")
    public String addCompanyClassify() {
        return "jsp/add_CompanyClassify";
    }

    // 跳转修改分类
    @RequestMapping("/updateCompanyClassify")
    public ModelAndView updateCompanyClassify(String id) {
        return new ModelAndView("jsp/update_CompanyClassify", "sClassify", companyClassifyService.selectByPrimaryKey(id));
    }
}
